package py.progweb.sgc.gui.server.service;

import javax.naming.NamingException;

import py.progweb.sgc.gui.client.service.PagoService;
import py.progweb.sgc.gui.client.service.RemoteServiceException;
import py.progweb.sgc.manager.PagosFacadeLocal;
import py.progweb.sgc.model.Pago;


public class PagoServiceImpl extends BaseServiceImpl implements PagoService { 
	PagosFacadeLocal mgr;
	
	public PagoServiceImpl() throws NamingException {
		this.mgr = (PagosFacadeLocal)getBean("PagosFacade");
	}
	
	public void guardar(Pago entity) throws RemoteServiceException {
		try {
			this.mgr.guardarPago(entity);
		}catch(Exception e) {
			throw manejarError(e);
		}
	}
	
	@Override
	public RemoteServiceException manejarError(Exception e) {
		e.printStackTrace();
		
		//logger.error("Ocurrio una excepcion: " + e.getClass().getName() + ": " + e.getMessage() + " causa: " + e.getCause().getMessage());
		logger.error(e.getMessage());
		String message = e.getMessage();
		/*if (e.getCause() != null){
			message = message + ": " + e.getCause().getMessage();
		}
		if (e.getCause().getCause() != null){
			message = message + ", " + e.getCause().getCause().getMessage();
		}*/
		return new RemoteServiceException(message);
	}
}
